﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace Mmht.DB
{
   public class MessageDB
    {
       public DataTable FindMessage() 
       {
           string sql = string.Empty;
           sql = "select * from message order by created_at desc";
           operate op = new operate();
           DataTable dt = op.Query(sql);
           return dt;
       }
       public bool InsertText(string text,string type,string created_by) 
       {
           string sql = string.Empty;
           DateTime now = DateTime.Now;
           sql = "insert into message(text,type,created_by,created_at)values('"+text .ToString ()+"','"+type.ToString ()+"','"+created_by .ToString ()+"','"+now +"') ";
           operate op = new operate();
           bool bl = op.Execute(sql);
           return bl;
       }
       public bool DelMessage(int id) 
       {
           string sql = string.Empty;
           sql = "delete from message where id ="+id.ToString ()+"";
           operate op = new operate();
           bool bl = op.Execute(sql);
           return bl;
       }
       public bool DelAllMessage()
       {
           string sql = string.Empty;
           sql = "delete from message";
           operate op = new operate();
           bool bl = op.Execute(sql);
           return bl;
       }
    }
}
